import { Vector3, MathUtils } from 'three';
import { SceneTime } from './SceneTime';
/**
 * 
 * 太阳
 * 
 */
export class Sun {

    vector: Vector3 = new Vector3();
    time: SceneTime;

    constructor(time: SceneTime) {
        this.time = time;
    }

    update() {
        const time = this.time;
        const azimuth = 180;
        const hour = Number(time.hour);
        const minute = Number(time.minute);
        const second = Number(time.second);
        const elevation = 36 * (hour * 3600 + minute * 60 + second - 6 * 3600) / 8640;
        let deg = 90 - elevation;           // 太阳的角度
        const phi = MathUtils.degToRad(deg);
        const theta = MathUtils.degToRad(azimuth);
        this.vector.setFromSphericalCoords(1, phi, theta);
    }

}